<include file="Public/min-header"/>

<div class="wrapper">
    <include file="Public/breadcrumb"/>
    <section class="content">
        <!-- Main content -->
        <div class="container-fluid">
            <div class="pull-right">
                <a href="javascript:history.go(-1)" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="返回"><i class="fa fa-reply"></i></a>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="fa fa-list"></i> 商品模板详情</h3>
                </div>
                <div class="panel-body">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab_tongyong" data-toggle="tab">商品模板</a></li>
                    </ul>
                    <!--表单数据-->
                    <form method="post" id="addEditGoodsTypeForm" onsubmit="return checkgoodsTypeName();">                    
                        <!--通用信息-->
                    <div class="tab-content">                 	  
                        <div class="tab-pane active" id="tab_tongyong">
                           
                            <table class="table table-bordered">
                                <tbody>
                                
              
                                <tr>
                                    <td width="150">模板名称:</td>
                                    <td>
                                        <input type="text" value="{$goodsTem.name}" class="form-control" name="name" style="width:350px;"/>
                                        <span id="err_name" style="color:#F00; display:none;">商品地区名称不能为空!!</span>                                        
                                    </td>
                                </tr> 
                                
                                <tr>
                                    <td width="150">排序号:</td>
                                    <td>
                                        <input type="text" value="{$goodsTem.sortid}" class="form-control" name="sortid" style="width:350px;"/>
                                        <span style="color:#F00; ">数字越小越靠前</span>                                        
                                    </td>
                                </tr>     
                                 <if condition="$pid eq ''">
                                 <tr>
                                    <td >所属分类:</td>
                                    <td>
                                      
                                      <select id="cat_id" name="cat_id" class="form-control" style="width:250px;">
								            <option value="1" <if condition="$goodsTem[cat_id] eq 1">selected</if>>尺码信息</option>
								            <option value="2" <if condition="$goodsTem[cat_id] eq 2">selected</if>>尺码测量图</option>
								          </select>
                                      
                                    </td>
                                </tr>   
                              	 <tr>
                                    <td>上传商品图片:</td>
                                    <td>
                                        <input type="button" value="上传图片"  onclick="GetUploadify(1,'','goods','call_back');"/>
                                        <input type="text" class="input-sm"  name="original_img" id="original_img" value="{$goodsTem.original_img}"/>
                                        <if condition="$goodsTem['original_img'] neq null">
                                            &nbsp;&nbsp;
                                            <a target="_blank" href="{$goodsTem.original_img}" id="original_img2">
                                                <img width="25" height="25" src="/Public/images/image_icon.jpg">
                                            </a>
                                        </if>
                                        <span id="err_original_img" style="color:#F00; display:none;"></span>					                                        
                                    </td>
                                </tr>        
					</if>
                                
               <if condition="$pid neq ''">
                                 <tr >
                                    <td >尺寸组:</td>
                                    <td>
                                      <table class="table table-bordered" id="goods_attr_table">                                
                               		 <tr><td>
                                      <select name="goods_type" id="goods_type" class="form-control" style="width:250px;">
                                        <option value="0">选择尺寸组</option>
                                        <foreach name="goodsType" item="vo" key="k" >
                                            <option value="{$vo.id}"<if condition="$goodsTem[goods_type] eq $vo[id]"> selected="selected" </if> >{$vo.name}</option>
                                        </foreach>                                        
										  </select></td></tr></table>
                                    </td>
                                </tr> 
                                    
					</if>
                                                
                                </tbody>                                
                                </table>
                        </div>                           
                    </div>              
                    <div class="pull-right">
                       
               <if condition="$pid neq ''">
                        <input type="hidden" name="parentid" value="{$pid}">
						</if>
                        <input type="hidden" name="goods_id" value="{$goodsTem.id}">
                        <input type="hidden" name="id" value="{$goodsTem.id}">
                        <button class="btn btn-primary" title="" data-toggle="tooltip" type="submit" data-original-title="保存"><i class="fa fa-save"></i></button>
                    </div>
			    </form><!--表单数据-->
                </div>
            </div>
        </div>    <!-- /.content -->
    </section>
</div>
<script>
	
	
/** 以下 商品属性相关 js*/
$(document).ready(function(){
	
    // 商品类型切换时 ajax 调用  返回不同的属性输入框
    $("#goods_type").change(function(){        
        var goods_id = $("input[name='goods_id']").val();
        var type_id = $(this).val();
            $.ajax({
                    type:'GET',
                    data:{goods_id:goods_id,type_id:type_id}, 
                    url:"/admin/Goods/ajaxGetTemAttrInput",
                    success:function(data){                            
                            $("#goods_attr_table tr:gt(0)").remove()
                            $("#goods_attr_table").append(data);
                    }        
            });			                
    });
	// 触发商品类型
	$("#goods_type").trigger('change');
    
});
 
	
               <if condition="$pid eq ''">
    // 上传商品图片成功回调函数
    function call_back(fileurl_tmp){
        $("#original_img").val(fileurl_tmp);
    	$("#original_img2").attr('href', fileurl_tmp);
    }
// 判断输入框是否为空
function checkgoodsTypeName(){
	var name = $("#addEditGoodsTypeForm").find("input[name='name']").val();
    if($.trim(name) == '')
	{
		$("#err_name").show();
		return false;
	}
	return true;
}</if>
</script>

</body>
</html>